/**
 * Created by Administrator on 2017/7/3.
 */
var vm = avalon.define({
    $id: 'caseCenter',
    caseData: [],
    columnId: [],
    currentCaseData:[],
    freshData:function (index) {
        this.currentCaseData = this.caseData[index];
    }
})
init()
function init() {
    var columnIdArr = get_Storage("serviceColumnId");
    console.log(columnIdArr);
    var currentId = '';
    for (var i = 0, len = columnIdArr.length; i < len; i++) {
        if (columnIdArr[i].name == "案例中心") {
            currentId = columnIdArr[i].id;
        }
    }
    getSolutionNumber(currentId)
}
function getSolutionNumber(id) {
    var _basePath = getChildUrl(id);
    console.log("getColumnData _basePath=" + _basePath);
    $.frontEngineAjax.ajaxRequest(function (data) {
        for (var i = 0, len = data.length; i < len; i++) {
            vm.columnId.push(data[i].number);
        }
        /*vm.solutionData = data;*/
        console.log("getSolutionData==" + vm.columnId[0])
        getSolutionData();
    }, _basePath);
}

var index = 0
function getSolutionData() {
    var length = vm.columnId.length;
    var _basePath = getDataUrl(vm.columnId[index]);
    console.log("getColumnData _basePath=" + _basePath);
    $.frontEngineAjax.ajaxRequest(function (data) {
        vm.caseData.push(data[0]);
        if(index<length){
            index++;
            getSolutionData();
        }else{
            vm.currentCaseData = vm.caseData[0];
        }
    }, _basePath);
    console.log("getColumnData _basePath=" + JSON.stringify(vm.caseData,null,4));
}